﻿#include <CommonUnits/Units/Distance.h>
#include <gtest/gtest.h>

TEST(DistanceTest, CastTest)
{
    EXPECT_EQ(CU::Meter(1e3), CU::Kilometer(1));
    EXPECT_EQ(CU::Kilometer(1e3), CU::Megameter(1));
    EXPECT_EQ(CU::Megameter(1e3), CU::Gigameter(1));
    EXPECT_EQ(CU::Gigameter(1e3), CU::Terameter(1));
    EXPECT_EQ(CU::Terameter(1e3), CU::Petameter(1));
    EXPECT_EQ(CU::Petameter(1e3), CU::Exameter(1));
    EXPECT_EQ(CU::Decimeter(1e1), CU::Meter(1));
    EXPECT_EQ(CU::Centimeter(1e2), CU::Meter(1));
    EXPECT_EQ(CU::Millimeter(1e3), CU::Meter(1));
    EXPECT_EQ(CU::Micrometer(1e3), CU::Millimeter(1));
    EXPECT_EQ(CU::Nanometer(1e3), CU::Micrometer(1));
    EXPECT_EQ(CU::Picometer(1e3), CU::Nanometer(1));
    EXPECT_EQ(CU::Femtometer(1e3), CU::Picometer(1));
    EXPECT_EQ(CU::Attometer(1e3), CU::Femtometer(1));
}

TEST(DistanceTest, Literals)
{
    using namespace CU::Distance::Literals;
    EXPECT_EQ(1e3_m, 1.0_km);
    EXPECT_EQ(1e3_km, 1.0_Mm);
    EXPECT_EQ(1e3_Mm, 1.0_Gm);
    EXPECT_EQ(1e3_Gm, 1.0_Tm);
    EXPECT_EQ(1e3_Tm, 1.0_Pm);
    EXPECT_EQ(1e3_Pm, 1.0_Em);
    EXPECT_EQ(1e1_dm, 1.0_m);
    EXPECT_EQ(1e2_cm, 1.0_m);
    EXPECT_EQ(1e3_mm, 1.0_m);
    EXPECT_EQ(1e3_um, 1.0_mm);
    EXPECT_EQ(1e3_nm, 1.0_um);
    EXPECT_EQ(1e3_pm, 1.0_nm);
    EXPECT_EQ(1e3_fm, 1.0_pm);
    EXPECT_EQ(1e3_am, 1.0_fm);
}

TEST(DistanceTest, ToUnit)
{
    using namespace CU::Distance::Literals;
    EXPECT_EQ(1e3_m, CU::Distance::toUnit<CU::Meter>(1, CU::Kilometer::unit()));
    EXPECT_EQ(1e3_km, CU::Distance::toUnit<CU::Kilometer>(1, CU::Megameter::unit()));
    EXPECT_EQ(1e3_Mm, CU::Distance::toUnit<CU::Megameter>(1, CU::Gigameter::unit()));
    EXPECT_EQ(1e3_Gm, CU::Distance::toUnit<CU::Gigameter>(1, CU::Terameter::unit()));
    EXPECT_EQ(1e3_Tm, CU::Distance::toUnit<CU::Terameter>(1, CU::Petameter::unit()));
    EXPECT_EQ(1e3_Pm, CU::Distance::toUnit<CU::Petameter>(1, CU::Exameter::unit()));
    EXPECT_EQ(1e1_dm, CU::Distance::toUnit<CU::Decimeter>(1, CU::Meter::unit()));
    EXPECT_EQ(1e2_cm, CU::Distance::toUnit<CU::Centimeter>(1, CU::Meter::unit()));
    EXPECT_EQ(1e3_mm, CU::Distance::toUnit<CU::Millimeter>(1, CU::Meter::unit()));
    EXPECT_EQ(1e3_um, CU::Distance::toUnit<CU::Micrometer>(1, CU::Millimeter::unit()));
    EXPECT_EQ(1e3_nm, CU::Distance::toUnit<CU::Nanometer>(1, CU::Micrometer::unit()));
    EXPECT_EQ(1e3_pm, CU::Distance::toUnit<CU::Picometer>(1, CU::Nanometer::unit()));
    EXPECT_EQ(1e3_fm, CU::Distance::toUnit<CU::Femtometer>(1, CU::Picometer::unit()));
    EXPECT_EQ(1e3_am, CU::Distance::toUnit<CU::Attometer>(1, CU::Femtometer::unit()));
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}